package qsl.utils;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.regex.*;

public class string {
	public static String Format(String source, Object... params) {
		Matcher m = Pattern.compile("\\{(\\d+)\\}").matcher(source);
		while (m.find()) source = source.replace(m.group(0), String.valueOf(params[Integer.valueOf(m.group(1))]));
		return source;
	}
	public static String Encode(String input) {
		try { return URLEncoder.encode(input, "GBK"); }
		catch (UnsupportedEncodingException e) { return ""; }
	}
	public static String Decode(String input) {
		try { return URLDecoder.decode(input, "GBK"); }
		catch (UnsupportedEncodingException e) { return ""; }
	}
	public static void main(String[] args)
	{
		System.out.print(string.Format("aa{0}{1}{0}", "bb", 22));
	}
}